package com.example.controller;

import com.example.cac409club.result.RestResult;
import com.example.model.dos.ClubMemberDO;
import com.example.model.dto.ClubMemberDTO;
import com.example.model.query.ClubMemberQuery;
import com.example.service.ClubMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 社团成员信息管理
 * </p>
 * @author 34448
 */
@Api(tags = "社团成员信息管理")
@RequestMapping("/club-member")
@RestController
public class ClubMemberController {

    @Autowired
    private ClubMemberService clubMemberService;

    /**
     * 新增社团成员
     * @param clubMemberDTO 社团成员信息
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增社团成员")
    public RestResult<Boolean> addClubMember(@Validated @RequestBody ClubMemberDTO clubMemberDTO) {
        return clubMemberService.addClubMember(clubMemberDTO);
    }

    /**
     * 编辑社团成员
     * @param clubMemberDTO 社团成员信息
     * @return
     */
    @PostMapping("/edit")
    @ApiOperation("编辑社团成员")
    public RestResult<Boolean> editClubMember(@Validated @RequestBody ClubMemberDTO clubMemberDTO) {
        return clubMemberService.editClubMember(clubMemberDTO);
    }

    /**
     * 删除社团成员
     * @param clubMemberQuery 社团成员查询条件
     * @return
     */
    @PostMapping("/delete")
    @ApiOperation("删除社团成员")
    public RestResult<Boolean> deleteClubMember(@Validated @RequestBody ClubMemberQuery clubMemberQuery) {
        return clubMemberService.deleteClubMember(clubMemberQuery);
    }

    /**
     * 查询社团成员
     * @param clubMemberQuery 社团成员查询条件
     * @return
     */
    @GetMapping("/info")
    @ApiOperation("查询社团成员")
    public RestResult<ClubMemberDO> getClubMemberInfo(@Validated ClubMemberQuery clubMemberQuery) {
        return clubMemberService.getClubMemberInfo(clubMemberQuery);
    }

    /**
     * 导入社团成员信息
     * @param filePath 文件路径
     * @return
     */
    @PostMapping("/import")
    @ApiOperation("导入社团成员信息")
    public RestResult<Boolean> importClubMemberInfo(@RequestParam("filePath") String filePath) {
        return clubMemberService.importClubMemberInfo(filePath);
    }

    /**
     * 导出社团成员信息
     * @param filePath 文件路径
     * @return
     */
    @PostMapping("/export")
    @ApiOperation("导出社团成员信息")
    public RestResult<Boolean> exportClubMemberInfo(@RequestParam("filePath") String filePath) {
        return clubMemberService.exportClubMemberInfo(filePath);
    }

    /**
     * 上传社团成员照片
     * @param userId 用户ID
     * @param file 文件
     * @return
     */
    @PostMapping("/upload-photo")
    @ApiOperation("上传社团成员照片")
    public RestResult<Boolean> uploadClubMemberPhoto(@RequestParam("userId") Integer userId, @RequestParam("file") MultipartFile file) {
        return clubMemberService.uploadClubMemberPhoto(userId, file);
    }

    /**
     * 上传社团成员证书
     * @param userId 用户ID
     * @param file 文件
     * @return
     */
    @PostMapping("/upload-certificate")
    @ApiOperation("上传社团成员证书")
    public RestResult<Boolean> uploadClubMemberCertificate(@RequestParam("userId") Integer userId, @RequestParam("file") MultipartFile file) {
        return clubMemberService.uploadClubMemberCertificate(userId, file);
    }
}